package com.fangrui.service.impl;

import com.fangrui.mapper.EmpMapper;
import com.fangrui.pojo.Emp;
import com.fangrui.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

//
// Created by ✎﹏ℳ๓独赏☆独醉 on 2025/4/22 18:19.
//
@Service
public class EmpServiceImpl implements EmpService {
    @Autowired
    private EmpMapper empMapper;
    @Override
    public long getTotal() {
        return empMapper.getTotal();
    }

    @Override
    public List<Emp> getAllEmps(Integer pageNum,Integer pageSize) {
        Integer start = (pageNum-1)*pageSize;
        return empMapper.getAllEmps(start,pageSize);
    }

    @Override
    public List<Emp> getAllEmps(String name, Short gender, LocalDate begin, LocalDate end) {
        return empMapper.getAllEmpsByConditions(name,gender,begin,end);
    }

    @Override
    public int deleteEmps(List<Integer> arr) {
        return empMapper.deleteEmps(arr);
    }

    @Override
    public int addEmp(Emp emp) {
        emp.setCreateTime(LocalDateTime.now());
        emp.setUpdateTime(LocalDateTime.now());
        return empMapper.addEmp(emp);
    }

    @Override
    public Emp getEmpById(Integer id) {
        return empMapper.getEmpById(id);
    }

    @Override
    public int updateEmp(Emp emp) {
        emp.setUpdateTime(LocalDateTime.now());
        return empMapper.updateEmp(emp);
    }

    @Override
    public Emp login(Emp emp) {
        return empMapper.login(emp);
    }
}
